import java.util.*;

class TreeNode {
    TreeNode left;
    TreeNode right;
    int val;
    public  TreeNode(int val) {
        this.val = val;
    }
}
public class E2T1 {
    public static  int i = 0;
    public static TreeNode createTree(String str) {
        TreeNode root = null;
        char ch = str.charAt(i);
        if(ch!='#') {
            root = new TreeNode(ch);
            i++;
            root.left = createTree(str);
            root.right = createTree(str);
        }else {
            i++;
        }
        return root;
    }
    public static int levelOrder(TreeNode root) {
        int res = 0;
        Queue<TreeNode> q = new LinkedList<>();
        q.offer(root);
        while(!q.isEmpty()) {
            int size = q.size();
            res = res>=size?res:size;
            while(size!=0) {
                TreeNode cur = q.poll();
                if(cur.left!=null) {
                    q.offer(cur.left);
                }
                if(cur.right!=null) {
                    q.offer(cur.right);
                }
                size--;
            }
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        TreeNode root = null;
        while (scanner.hasNextLine()) {
            String str = scanner.nextLine();
            root = createTree(str);
        }
        System.out.println(levelOrder(root));
    }
}
